﻿using System;
using Dukous.BizService;
using Dukous.Security.Domain;
using System.Collections.Generic;

namespace Dukous.Security.BizService
{
    /// <summary>
    /// 安全服务接口
    /// </summary>
    public interface ISecurityService : IEntityBizService<User, long>
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        User this[string index] { get; }

        /// <summary>
        /// 尝试登录
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <param name="ip"></param>
        /// <returns></returns>
        LogonInfo TryLogon(string userName, string password, string ip);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="logonInfo"></param>
        /// <returns></returns>
        string DoLogon(LogonInfo logonInfo);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="logonInfo"></param>
        void Logoff(LogonInfo logonInfo);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="guid"></param>
        /// <param name="ip"></param>
        /// <returns></returns>
        LogonInfo FindLogonInfo(Guid guid, string ip);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="user"></param>
        /// <param name="obj"></param>
        /// <param name="permission"></param>
        /// <returns></returns>
        bool CheckPermission(User user, string obj, string permission);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="user"></param>
        /// <param name="obj"></param>
        /// <param name="field"></param>
        /// <param name="permission"></param>
        /// <returns></returns>
        bool CheckPermission(User user, string obj, string field, string permission);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="group"></param>
        /// <param name="obj"></param>
        /// <param name="permission"></param>
        /// <returns></returns>
        bool CheckPermission(Group group, string obj, string permission);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="group"></param>
        /// <param name="obj"></param>
        /// <param name="field"></param>
        /// <param name="permission"></param>
        /// <returns></returns>
        bool CheckPermission(Group group, string obj, string field, string permission);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        SecurityObjectPermission FindSecurityObjectPermissionById(long id);

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        IList<SecurityObjectPermission> SelectAllSecurityObjectPermissions();
    }
}
